package org.easy.tool.controller;

import org.easy.tool.common.PdfUtil;
import org.easy.tool.common.R;
import org.easy.tool.service.IFileRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.LinkedHashMap;

/**
 * 文件
 *
 * @author Valley
 * @since 2024-09-08 13:27:04
 */
@RestController
@RequestMapping("/fileRecord")
@CrossOrigin
public class FileRecordController {

    @Autowired
    IFileRecord fileRecordService;


    @RequestMapping("upload")
    public R upload(MultipartFile file) throws Exception {
        String fileRecordId = fileRecordService.upload(file);
        return R.ok(fileRecordId);
    }

    @RequestMapping("/{id}")
    public void preview(@PathVariable(value = "id") String id) throws Exception {
        fileRecordService.preview(id);
    }


    @RequestMapping("exportWord")
    public void exportWord(@RequestBody(required = false)LinkedHashMap data) throws Exception {
        fileRecordService.exportWord(data);
    }

}
